/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Action;

import ActionForm.mobListaPedidosClienteActionForm;
import BE.Pedido;
import BL.PedidoBL;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;

/**
 *
 * @author dennis
 */
public class mobListaPedidosClienteAction extends org.apache.struts.action.Action {
    
    /* forward name="success" path="" */
    private final static String SUCCESS = "success";
    
    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @throws java.lang.Exception
     * @return
     */
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        mobListaPedidosClienteActionForm objPedidoForm = new mobListaPedidosClienteActionForm(request);
        PedidoBL objPedidoBL = new PedidoBL();
        String idCliente=request.getParameter("IdCliente");
        int intIdUsuario = (Integer) request.getSession().getAttribute("uid");
        request.getSession().setAttribute("IdCliente", idCliente);
        List<Pedido> arrPedidos = objPedidoBL.buscarCliente(intIdUsuario,Integer.parseInt(idCliente));
        //List<Cliente> arrClientes = objClienteBL.buscarCliente(objClienteBE);

        if((arrPedidos!=null)&&(arrPedidos.size()>0))
        {
        request.setAttribute("arrPedidos", arrPedidos);
        return mapping.findForward("mostrarPedido");

        }
        else
        {
            request.setAttribute("strMensaje", "El cliente no ha Registrado Pedidos");
            return mapping.findForward("mobMenuPrincipal");
        }
        
    }
}
